#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e3+10;
int n,m,a[MAXN][MAXN],x[MAXN],y[MAXN],top,ans;
void solve(int b[])
{
	top=0;
	for(int i=1;i<=m;++i)
	{
		if(b[i]>=y[top])
		{
			y[++top]=b[i];
			x[top]=1;
		}
		else
		{
			int len=0;
			while(top&&y[top]>b[i])
			{
				len+=x[top];
				ans=max(ans,len*y[top]);
				--top;
			}
			y[++top]=b[i];
			x[top]=len+1;
		}
	}
	int len=0;
	while(top)
	{
		len+=x[top];
		ans=max(ans,len*y[top]);
		--top;
	}
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	char temp[3];
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			scanf("%s",temp);
			if(temp[0]=='F')a[i][j]=a[i-1][j]+1;
		}
	for(int i=1;i<=n;++i)solve(a[i]);
	printf("%d\n",ans*3);
	return 0;
}
